<?php
/**
 * Created by PhpStorm.
 * User: cephei
 * Date: 10/16/15
 * Time: 4:25 PM
 */

namespace App\Http\Practice\Lib;

class RapidCalculation
{
    static function getFormulas($count = 4)
    {
        $list = array();
        for ($z = 0; $z <= $count; $z++) {
            $type = rand(1, 6);
            if ($type == 1) { // 头同尾互补
                $i11 = rand(1, 9);
                $i12 = rand(1, 9);
                $i21 = $i11;
                $i22 = 10 - $i12;
                $list[] = $i11 . $i12 . ' x ' . $i21 . $i22 . ' = ';
            } else if ($type == 2) { // 尾同头互补
                $i11 = rand(1, 9);
                $i12 = rand(1, 9);
                $i21 = 10 - $i11;
                $i22 = $i12;
                $list[] = $i11 . $i12 . ' x ' . $i21 . $i22 . ' = ';
            } else if ($type == 3) { // 乘11
                $i11 = rand(1, 9);
                $i12 = rand(1, 9);
                $direction = rand(0, 1);
                if ($direction) {
                    $list[] = $i11 . $i12 . ' x 11 = ';
                } else {
                    $list[] = '11 x ' . $i11 . $i12 . ' = ';
                }
            } else if ($type == 4) { // 乘5
                $i11 = rand(1, 9);
                $i12 = rand(1, 9);
                $direction = rand(0, 1);
                if ($direction) {
                    $list[] = $i11 . $i12 . ' x 5 = ';
                } else {
                    $list[] = '5 x ' . $i11 . $i12 . ' = ';
                }
            } else if ($type == 5) { // 乘15
                $i11 = rand(1, 9);
                $i12 = rand(1, 9);
                $direction = rand(0, 1);
                if ($direction) {
                    $list[] = $i11 . $i12 . ' x 15 = ';
                } else {
                    $list[] = '15 x ' . $i11 . $i12 . ' = ';
                }
            } else { // 乘25
                $i11 = rand(1, 9);
                $i12 = rand(1, 9);
                $direction = rand(0, 1);
                if ($direction) {
                    $list[] = $i11 . $i12 . ' x 25 = ';
                } else {
                    $list[] = '25 x ' . $i11 . $i12 . ' = ';
                }
            }
        }
        return $list;
    }
}